package com.example.config;

import com.example.filter.MyFilter;
import com.example.servlet.MyServlet;
import org.springframework.web.WebApplicationInitializer;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

public class MyWebInitializer implements WebApplicationInitializer{

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        ServletRegistration.Dynamic myServlet = servletContext.addServlet("myServlet", MyServlet.class);
        myServlet.addMapping("/my");

        javax.servlet.FilterRegistration.Dynamic myFileter = servletContext.addFilter("myFileter", MyFilter.class);
        myFileter.addMappingForUrlPatterns(null, false, "/my");
    }
}
